package com.tiyende.kash.loop.base;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;

import com.tiyende.kash.loop.R;
import com.tiyende.kash.loop.ui.dialog.TiyendeLoading;
import com.tiyende.kash.loop.utils.TiyendeToastManager;

public abstract class BaseDialog extends Dialog implements IBaseView,View.OnClickListener {

    public BaseDialog(Context context) {
        super(context, R.style.DialogTheme);
    }

    public BaseDialog(Context context, int style) {
        super(context, style);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getTiyendeRootView());
        initTiyendeWindow();
        initTiyendeView();
        initTiyendeListener();
        loadTiyendeData();
    }

    protected abstract View getTiyendeRootView();

    /**
     * 初始化Window
     */
    protected abstract void initTiyendeWindow();

    /**
     * 初始化布局
     */
    protected abstract void initTiyendeView();

    /**
     * 初始化监听
     */
    protected abstract void initTiyendeListener();

    /**
     * 初始化数据
     */
    protected abstract void loadTiyendeData();

    /**
     * 控件点击事件
     */
    protected abstract void onTiyendeViewClick(View v);

    @Override
    public void showTiyendeLoading() {
        TiyendeLoading.Companion.show(getContext(),false,false,"");
    }

    @Override
    public void hiddenTiyendeLoading() {
        TiyendeLoading.Companion.dismiss(getContext());
    }

    @Override
    public void showTiyendeToast(String s) {
        TiyendeToastManager.showShortText(getContext(), s);
    }

    @Override
    public void onClick(View v) {
        onTiyendeViewClick(v);
    }

    protected void setOnClickListener(View view) {
        view.setOnClickListener(this);
    }
}
